/**
 * Project Name:fire-industry-DM-center
 * File Name:BaseServer.java
 * Package Name:com.firestone.web
 * Date:2018年3月30日上午10:57:08
 *
*/

package com.firestone.web;

import org.springframework.security.core.context.SecurityContextHolder;

import com.firestone.bean.dto.user.User;
import com.firestone.core.exception.FireAccessDeniedException;

/**
 * @Description: TODO(基础控制器)
 * @author CAIYJ
 * @date 2018年3月30日 上午10:57:08
 */
public class BaseServer {

    public final User getUserInfo() {
        User user = (User) SecurityContextHolder.getContext()
                .getAuthentication().getPrincipal();
        if (null == user) {
            throw new FireAccessDeniedException("用户未登录或会话已超时", null);
        }
        return user;
    }
}
